
package com.shangsi.service;

import com.alibaba.csp.sentinel.AsyncEntry;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author dzd
 * @date 2021-12-14
 */
@Service
public class AsyncService {

    @Async
    public void doSomethingAsync(AsyncEntry asyncEntry){

        System.out.println("async start ...");
        try {
            TimeUnit.SECONDS.sleep(4);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (asyncEntry!=null){
                asyncEntry.exit();
            }
        }
        System.out.println("async end ....");

    }
}
